Skip to content

[Repo Assist] Add regression test for unnecessary parens in chained method call (issue #1362)#1483

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-issue-1362-test-chained-call-parens-6cd427f6bea753be
Draft

[Repo Assist] Add regression test for unnecessary parens in chained method call (issue #1362)#1483
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-issue-1362-test-chained-call-parens-6cd427f6bea753be

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist.

Closes #1362

Summary

Adds a checkNotApplicable regression test for the bug reported in #1362, where the UnnecessaryParenthesesAnalyzer incorrectly suggests removing parentheses that are necessary to disambiguate a chained method call with a float literal argument.

Bug scenario:

bg.lighten(0.2).hexa ()
//         ^^^^ FSAC0004 incorrectly suggests these parens can be removed

Removing the parentheses produces invalid F# code:

bg.lighten 0.2.hexa ()  // ❌ invalid: 0.2.hexa is parsed as field access on numeric literal

Root Cause (from upstream analysis)

The bug is in FSharp.Compiler.Service — the "dot-safe numeric literal" case was evaluated before the "fluent call requires parens" case in SynExpr.fs. Fixed upstream at dotnet/fsharp#18350.

Test Design

The test uses checkNotApplicable with Diagnostics.acceptAll so it:

  • Fails when the upstream bug is still present (the code fix IS incorrectly offered)
  • Passes once the FCS fix makes it into the SDK (the code fix is NOT offered, and the diagnostic may or may not be raised)

Test Status

Build: ✅ dotnet build succeeded with 0 warnings and 0 errors.

Tests were not run in full as this test requires an LSP server environment — it is a live integration test. The build confirms the test compiles correctly.

Generated by Repo Assist for issue #1362

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

…thod call

Add a checkNotApplicable test verifying that parentheses around a float
literal argument in a chained method call are NOT suggested for removal.

  bg.lighten(0.2).hexa ()  -- parens around 0.2 are necessary

Without the fix (from dotnet/fsharp#18350), removing the parens produces
invalid code: bg.lighten 0.2.hexa ()

The test uses Diagnostics.acceptAll so it remains valid whether or not
FSAC0004 is raised -- it simply asserts the code fix is not offered.

Closes #1362

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unnecessary parentheses analyzer trigger in chained function call

0 participants